package com.my.spring.framework.aop.intercept;

import com.my.spring.framework.aop.aspect.MyAbstractAspectAdvice;
import lombok.Getter;
import lombok.Setter;

import java.lang.reflect.Method;

@Getter
@Setter
public class MyThrowsAdviceInterceptor extends MyAbstractAspectAdvice implements MyMethodInterceptor {
    private String throwName;

    public MyThrowsAdviceInterceptor(Method method, Object target) {
        super(method, target);
    }

    @Override
    public Object invoke(MyMethodInvocation mi) throws Throwable {
        try {
            return mi.proceed();
        } catch (Throwable e) {
            invokeAdviceMethod(mi, null, e.getCause());
            throw e;
        }
    }
}
